package top.hidoctor.auscultation.feature.activity;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import java.util.ArrayList;

import top.hidoctor.auscultation.R;
import top.hidoctor.auscultation.adapter.AdapterViewpager;
import top.hidoctor.auscultation.base.BaseActivity;

public class ShowImgActivity extends BaseActivity {
    ViewPager viewpageer;
    TextView tvIndex;
    private int index;
    private AdapterViewpager viewpager;
    private ArrayList<String> imags;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
        setContentView(R.layout.activity_show_imgs);
        viewpageer=   findViewById(R.id.viewpageer);
        tvIndex=   findViewById(R.id.tvIndex);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏
        if (getIntent().hasExtra("imgs")) {
            imags = getIntent().getStringArrayListExtra("imgs");
            index = getIntent().getIntExtra("index", 0);
        } else {
            finish();
            return;
        }
        AdapterViewpager adapter = new AdapterViewpager(imags);
        viewpageer.setAdapter(adapter);
        viewpageer.setCurrentItem(index);
        tvIndex.setText((index+1)+"/"+imags.size());
        viewpageer.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                index=position;
                tvIndex.setText((index+1)+"/"+imags.size());
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }
}
